package com.lh.controller;

import com.alibaba.dubbo.config.annotation.Reference;
import com.alibaba.dubbo.config.spring.context.annotation.DubboComponentScan;
import com.lh.dto.AgeDto;
import com.lh.dto.IdDto;
import com.lh.dto.NameDto;
import com.lh.service.DemoService;

import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@DubboComponentScan(basePackages = "com.lh.controller")
@RestController
public class DubboTestController {

    @Reference(version = "1.0.0", check = true)
    DemoService demoService;

    @RequestMapping("/test")
    public String test() {
        AgeDto ageDto = new AgeDto();
        ageDto.setId(0L);
        ageDto.setAge(18L);
        demoService.age(ageDto);
        IdDto idDto = new IdDto();
        idDto.setId(1L);
        demoService.dto(idDto);
        NameDto nameDto = new NameDto();
        nameDto.setName("lily");
        nameDto.setId(2L);
        demoService.name(nameDto);
        return demoService.hello("hello test");

    }

    @RequestMapping("/hello")
    public String hello() {
        return "hello world";
    }


}